﻿<%@ Page Title="" Language="C#" MasterPageFile="~/RealTwitterApp.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Twitter.Index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
 <%= "Tweets de " + (Session["auth"] as LinqToTwitter.WebAuthorizer).ScreenName %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="pageTitle" runat="server">
<%if (user != null)
  { %>
	  <img alt="" src="<%=user.ProfileImageUrl %>" height="32" width="32" style="float:left" />
    <%="Fil d'actualité de " + user.Identifier.ScreenName%>
    <%}
  else
  {  
        %>
        <%="Fil d'actualité " %>
        <%
            } %>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="pageContent" runat="server">
   <div>  
       <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
           ControlToValidate="txtTweet" ErrorMessage="Ecrivez le tweet"></asp:RequiredFieldValidator>
    <asp:TextBox TextMode="MultiLine"  Columns="50" ID="txtTweet"  CssClass="tweets" runat="server" 
           Width="300px" Height="47px" MaxLength="140"/>
           <br />
    <asp:Button  id="searchBtn"  runat="server" 
           Text="Tweeter" onclick="doTweetClicked" />  
   </div>
     
 <p>
 </p>
     <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
 <div class="post_body nicelist">
<ol>
     <% 
            List<LinqToTwitter.Status> lst = getUserTweets();
            bool alt = true;
            if (lst != null)

                foreach (LinqToTwitter.Status tw in lst)
                {
                    this.tweetId = tw.StatusID;
                    String altClass = alt ? "alt" : "";
                    alt = !alt;
   %>
        <li  class="<%=altClass %>">

						<div class="comment_gravatar left">
							<img alt="" src="<%=tw.User.ProfileImageUrl %>" height="32" width="32" />
						</div>

						<div class="comment_author left">
							<span class="comment">@<b><a href="AmisTweets.aspx?userid=<%=tw.User.Identifier.UserID %>"><%=tw.User.Identifier.ScreenName%>&nbsp;&nbsp;</b><%=tw.User.Name%></a></span><div class="date"><%=tw.CreatedAt%></div>
						</div>

						<div class="clearer">&nbsp;</div>
						
						<div class="body">									
							<p><%=tw.Text%></p>
						</div>
		               <div><span style="margin-left: 30%">
         <%
            //if (tw.User.Identifier.UserID == userId)
            {
           %>
         <a href="Index.aspx?delete=<%=tweetId %>"  > Supprimer</a> | 
         <%} %>
          <a href="Index.aspx?retweet=<%=tweetId %>&text=<%=Server.UrlEncode(tw.Text) %>" >Retweeter</a> | <a href="Index.aspx?modifier=<%=tweetId %>&text=<%=Server.UrlEncode(tw.Text) %>" >Modifier</a></span></div>
					</li>		
        
     <%} %>
</ol> 
</div>  
    
    </ContentTemplate>
    </asp:UpdatePanel>

    <asp:Timer ID="Timer1" runat="server" Interval="30000" ontick="reloadTweets" >
    </asp:Timer>


</asp:Content>

